<?php

class GXMLParser {
	var $xml;
	var $color;
	var $gps = array(
		'Morocco'   =>   array(31.91, -6.50),
		'Algeria'   =>   array(28.15, 2.29),
		'Tunisia'   =>   array(34.16, 9.54),
		'Libya'     =>   array(26.90, 17.67),
		'Egypt'	  =>   array(26.43, 29.71),
		'Western Sahara'  =>   array(24.81, -13.23),
		'Mauritania' =>   array(20.30, -10.37),
		'Mali'      =>   array(17.81, -1.80),
		'Niger'     =>   array(17.43, 9.27),
		'Chad'      =>   array(15.37, 18.68),
		'Sudan'     =>   array(13.84, 29.93),
		'Ethopia'   =>   array(8.15, 41.09),
		'Kenya'     =>   array(0.53, 37.75),
		'Uganda'    =>   array(1.45, 32.39),
		'Congo'     =>   array(-2.72, 23.38),
		'Gabon'     =>   array(-0.62, 11.65),
		'Angola'    =>   array(-12.34, 17.58),
		'Zambia'  =>   array(-13.67, 27.86),
		'Tanzania'  =>   array(-6.40, 34.76),
		'Mozambique' =>  array(-17.35, 35.55),
		'Botswana'  =>   array(-22.15, 23.73),
		'Nambia'    =>   array(-21.82, 16.83),
		'Zimbabwe'  =>   array(-19.06, 29.88),
		'South Africa'  =>   array(-30.07, 25.00),
		'Central African Republic'       =>   array(6.58, 20.39),
		'Camaroon'  =>   array(5.57, 12.44),
		'Nigeria'   =>   array(9.49, 7.82),
		'Ghana'     =>   array(8.93, 0.62),
		'Ivory Coast'=> array(7.62, -5.67),
		'Guinea'    =>   array(9.71, -11.03),
		'Senegal'   =>   array(14.35, -14.41)
	);
	
	function openXML() {
		$this->xml = "<markers>";		
	}
	
	function addFlag( $name ) {
		$loc1 = 0;
		$loc2 = 0;
		if( isset( $gps[$name][0] ) ) {
			$loc1 = $gps[$name][0];
		}
		if( isset( $gps[$name][1] ) ) {
			$loc2 = $gps[$name][1];
		}
	
		$this->xml .= "<marker lat='".$loc1."' lng='".$loc2."'><info>No info</info></marker>";
	}
	
	function addRegionFlag( $name ) {
		$loc1 = 0;
		$loc2 = 0;
		$this->color = 'blue';
		if( isset( $this->gps[$name][0] ) ) {
			$loc1 = $this->gps[$name][0];
		}
		if( isset( $this->gps[$name][1] ) ) {
			$loc2 = $this->gps[$name][1];
		}
		$this->xml .= "<marker lat='".$loc1."' lng='".$loc2."'><info>Region Name: ".$name."</info></marker>";
	}
	
	function addSpeciesFlag( $name, $pop ) {
		$loc1 = 0;
		$loc2 = 0;
		$this->color = 'red';
		if( isset( $this->gps[$name][0] ) ) {
			$loc1 = $this->gps[$name][0];
		}
		if( isset( $this->gps[$name][1] ) ) {
			$loc2 = $this->gps[$name][1];
		}
		$this->xml .= "<marker lat='".$loc1."' lng='".$loc2."'><info>Population: ".$pop."</info></marker>";
	}
	
	function closeXML() {
		$this->xml .= "</markers>";
		echo "getMarkers(\"".$this->xml."\", \"".$this->color."\");";
	}
	
	function closeXMLWithTags() {
		$this->xml .= "</markers>"; 
		echo "<script type='text/javascript'>getMarkers(\"".$this->xml."\", \"".$this->color."\");</script>";
	}
}

?>